<? 
		if(isset($_POST['btnsubmit']))
		{
			require("required/dbconnect.php"); 
			
			$content_eng=$_POST['content_eng'];
			$type=$_POST['type'];
			$brief_description= mysql_escape_string($_POST['brief_description']);
			$insert=mysql_query("update os_contents set content='$content_eng',brief_description='$brief_description' where content_type='$type'")or die(mysql_error());
			
			header("Location:content.php?type=$type&msg=1");
?>
			
<?			
		
		}
		else
		{
				
				require("required/dbconnect.php"); 
				require("required/function.php"); 
				require("required/header.php"); 
				
				if(empty($_GET['type']))
				{
					die("Illegal Action!!");
				}
				
				$type=$_GET['type'];
				
				
				
				$get_content=mysql_query("select * from os_contents where content_type='$type'")or die(mysql_error());
				
				if(mysql_num_rows($get_content)==0)
				{
					die("Illegal Action!!");
				}
				$a=mysql_fetch_array($get_content,MYSQL_ASSOC);
				if(empty($_GET['msg']))
				{
					$msg="";
				}
				else
				{
					$msg="<font color=green><strong>Data updated!</strong></font>";
				}
?>
				
				<table width="100%"  cellpadding="0" cellspacing="5" height="300">
				
					<td class="solidborder" width="84%" align="left" valign="top">
					
						<form action="<?= $_SERVER['PHP_SELF'] ?>" name="frm" method="post" onSubmit="return validatefrm(this)">
						<table width="100%">
						
						<td class="title" colspan="2">
						<?= $msg ?><br>
						<strong><?= $a['title'] ?> Management</strong></td>
						
						
						<tr valign="top">
							<td width="17%">Title</td><td width="83%"><input type="text" value="<?= $a['title'] ?>" size="50" maxlength="200"></td>
						</tr>
						<?
							if($type=="history" || $type=="product_services"){
						?>
						<tr valign="top">
							<td>Brief Description at home page</td><td>
							<textarea rows="5" cols="60" name="brief_description"><?= $a['brief_description'] ?></textarea>
							</td>
						</tr>
						<? }else{ ?>
						<input type="hidden" value="" name="brief_description">
						<? } ?>						
						<tr valign="top">
							<td>Content</td>
							<td valign="top">
							<? include_once("fckeditor/fckeditor.php") ?>
							<?php
								$oFCKeditor = new FCKeditor('content_eng') ;
								$oFCKeditor->ToolbarSet = 'DeswinBasic';
								$oFCKeditor->Height = 500 ;
								$oFCKeditor->BasePath = './fckeditor/' ;
								$oFCKeditor->Value = $a["content"] ;
								$oFCKeditor->Create() ;
							?>

								
							</td>
						</tr>
						<input type="hidden" value="<?= $type ?>" name="type">
						<tr>
							<td colspan="2"><input type="submit" value="Submit" name="btnsubmit"></td>
						</tr>
						</table>
						</form>
					</td>
				 
				</table>
<? }require("required/footer.php"); ?>